<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222" media="(prefers-color-scheme: light)">
<meta name="theme-color" content="#222" media="(prefers-color-scheme: dark)"><meta name="generator" content="Hexo 7.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" integrity="sha256-dABdfBfUoC8vJUBOwGVdm8L9qlMWaHTIfXt+7GnZCIo=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/themes/black/pace-theme-flat-top.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/pace.min.js" integrity="sha256-gqd7YTjg/BtfqWSwsJOvndl0Bxc8gFImLEkXQT8+qj0=" crossorigin="anonymous" defer></script>

<script class="next-config" data-name="main" type="application/json">{"hostname":"tryhub.top","root":"/","images":"/images","scheme":"Gemini","darkmode":true,"version":"8.23.0","exturl":false,"sidebar":{"position":"left","width_expanded":320,"width_dual_column":240,"display":"post","padding":18,"offset":12},"hljswrap":true,"copycode":{"enable":true,"style":"mac"},"fold":{"enable":false,"height":500},"bookmark":{"enable":true,"color":"#222","save":"manual"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"duration":200,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.json","localsearch":{"enable":true,"top_n_per_article":1,"unescape":true,"preload":true,"trigger":"auto"}}</script><script src="/js/config.js" defer></script>

    <meta name="description" content="微信提现-企业付款到零钱p12证书下载 企业付款到零钱API  apiclient_cert.p12证书:微信商户平台 – 账户设置 – API安全 – 证书中下载">
<meta property="og:type" content="article">
<meta property="og:title" content="微信提现-企业付款到零钱">
<meta property="og:url" content="https://tryhub.top/2019/05/17/%E5%BE%AE%E4%BF%A1%E6%8F%90%E7%8E%B0-%E4%BC%81%E4%B8%9A%E4%BB%98%E6%AC%BE%E5%88%B0%E9%9B%B6%E9%92%B1/index.html">
<meta property="og:site_name" content="奇姆的博客">
<meta property="og:description" content="微信提现-企业付款到零钱p12证书下载 企业付款到零钱API  apiclient_cert.p12证书:微信商户平台 – 账户设置 – API安全 – 证书中下载">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2019-05-17T02:30:37.000Z">
<meta property="article:modified_time" content="2023-07-07T07:27:34.152Z">
<meta property="article:author" content="Jaron Chim">
<meta property="article:tag" content="WeChat">
<meta name="twitter:card" content="summary">


<link rel="canonical" href="https://tryhub.top/2019/05/17/%E5%BE%AE%E4%BF%A1%E6%8F%90%E7%8E%B0-%E4%BC%81%E4%B8%9A%E4%BB%98%E6%AC%BE%E5%88%B0%E9%9B%B6%E9%92%B1/">


<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"https://tryhub.top/2019/05/17/%E5%BE%AE%E4%BF%A1%E6%8F%90%E7%8E%B0-%E4%BC%81%E4%B8%9A%E4%BB%98%E6%AC%BE%E5%88%B0%E9%9B%B6%E9%92%B1/","path":"2019/05/17/微信提现-企业付款到零钱/","title":"微信提现-企业付款到零钱"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>微信提现-企业付款到零钱 | 奇姆的博客</title>
  

  <script src="/js/third-party/analytics/baidu-analytics.js" defer></script>
  <script async src="https://hm.baidu.com/hm.js?1ad13b7aff8bfe9206fa7e12d5c4a4f0"></script>







  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous" defer></script>
<script src="/js/utils.js" defer></script><script src="/js/motion.js" defer></script><script src="/js/sidebar.js" defer></script><script src="/js/next-boot.js" defer></script><script src="/js/bookmark.js" defer></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.1/search.js" integrity="sha256-1kfA5uHPf65M5cphT2dvymhkuyHPQp5A53EGZOnOLmc=" crossorigin="anonymous" defer></script>
<script src="/js/third-party/search/local-search.js" defer></script>





  <script src="/js/third-party/pace.js" defer></script>


  
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>





  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<link rel="alternate" href="/atom.xml" title="奇姆的博客" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">奇姆的博客</p>
      <i class="logo-line"></i>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li><li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a></li><li class="menu-item menu-item-sitemap"><a href="/sitemap.xml" rel="section"><i class="fa fa-sitemap fa-fw"></i>站点地图</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
      <div class="search-header">
        <span class="search-icon">
          <i class="fa fa-search"></i>
        </span>
        <div class="search-input-container">
          <input autocomplete="off" autocapitalize="off" maxlength="80"
                placeholder="搜索..." spellcheck="false"
                type="search" class="search-input">
        </div>
        <span class="popup-btn-close" role="button">
          <i class="fa fa-times-circle"></i>
        </span>
      </div>
      <div class="search-result-container">
        <div class="search-result-icon">
          <i class="fa fa-spinner fa-pulse fa-5x"></i>
        </div>
      </div>
    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%BE%AE%E4%BF%A1%E6%8F%90%E7%8E%B0-%E4%BC%81%E4%B8%9A%E4%BB%98%E6%AC%BE%E5%88%B0%E9%9B%B6%E9%92%B1"><span class="nav-number">1.</span> <span class="nav-text">微信提现-企业付款到零钱</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#p12%E8%AF%81%E4%B9%A6%E4%B8%8B%E8%BD%BD"><span class="nav-number">1.1.</span> <span class="nav-text">p12证书下载</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83-%E5%8F%82%E6%95%B0%E5%87%86%E5%A4%87"><span class="nav-number">1.2.</span> <span class="nav-text">开发环境&#x2F;参数准备</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#pom-xml%E7%9B%B8%E5%85%B3jar%E5%8C%85-%E6%8F%92%E4%BB%B6%E5%BC%95%E5%85%A5"><span class="nav-number">1.3.</span> <span class="nav-text">pom.xml相关jar包&#x2F;插件引入</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0"><span class="nav-number">1.4.</span> <span class="nav-text">代码实现</span></a></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="Jaron Chim"
      src="/images/jaron.gif">
  <p class="site-author-name" itemprop="name">Jaron Chim</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">76</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">95</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/tags/">
        <span class="site-state-item-count">144</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://github.com/admin-Jaron" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;admin-Jaron" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:tryhub@tryhub.top" title="E-Mail → mailto:tryhub@tryhub.top" rel="noopener me"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>

        </div>
      </div>
        <div class="back-to-top animated" role="button" aria-label="返回顶部">
          <i class="fa fa-arrow-up"></i>
          <span>0%</span>
        </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://tryhub.top/2019/05/17/%E5%BE%AE%E4%BF%A1%E6%8F%90%E7%8E%B0-%E4%BC%81%E4%B8%9A%E4%BB%98%E6%AC%BE%E5%88%B0%E9%9B%B6%E9%92%B1/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/jaron.gif">
      <meta itemprop="name" content="Jaron Chim">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="奇姆的博客">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="微信提现-企业付款到零钱 | 奇姆的博客">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          微信提现-企业付款到零钱
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2019-05-17 10:30:37" itemprop="dateCreated datePublished" datetime="2019-05-17T10:30:37+08:00">2019-05-17</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar-check"></i>
      </span>
      <span class="post-meta-item-text">更新于</span>
      <time title="修改时间：2023-07-07 15:27:34" itemprop="dateModified" datetime="2023-07-07T15:27:34+08:00">2023-07-07</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/WeChat/" itemprop="url" rel="index"><span itemprop="name">WeChat</span></a>
        </span>
    </span>

  
    <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv">
      <span class="post-meta-item-icon">
        <i class="far fa-eye"></i>
      </span>
      <span class="post-meta-item-text">阅读次数：</span>
      <span id="busuanzi_value_page_pv"></span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><h1 id="微信提现-企业付款到零钱"><a href="#微信提现-企业付款到零钱" class="headerlink" title="微信提现-企业付款到零钱"></a>微信提现-企业付款到零钱</h1><h2 id="p12证书下载"><a href="#p12证书下载" class="headerlink" title="p12证书下载"></a>p12证书下载</h2><ul>
<li><p><a target="_blank" rel="noopener" href="https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_1">企业付款到零钱API</a></p>
</li>
<li><p><a target="_blank" rel="noopener" href="https://pay.weixin.qq.com/">apiclient_cert.p12证书:微信商户平台 – 账户设置 – API安全 – 证书中下载</a></p>
</li>
</ul>
<span id="more"></span>

<h2 id="开发环境-参数准备"><a href="#开发环境-参数准备" class="headerlink" title="开发环境&#x2F;参数准备"></a>开发环境&#x2F;参数准备</h2><ul>
<li><p>SpringBoot2.0框架 （仅限本例，其他框架自行解决，原理相同）</p>
</li>
<li><p>APP_ID （公众账号appid）</p>
</li>
<li><p>MCH_ID（商户号）</p>
</li>
<li><p>API_SECRET（API密钥）</p>
</li>
</ul>
<h2 id="pom-xml相关jar包-插件引入"><a href="#pom-xml相关jar包-插件引入" class="headerlink" title="pom.xml相关jar包&#x2F;插件引入"></a>pom.xml相关jar包&#x2F;插件引入</h2><ul>
<li>xml相关jar包引入（微信接口要求以xml格式传参）</li>
</ul>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">dependencies</span>&gt;</span></span><br><span class="line">  <span class="comment">&lt;!-- xml --&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>net.sf.kxml<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>kxml2<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">version</span>&gt;</span>2.3.0<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>xmlpull<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>xmlpull<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">version</span>&gt;</span>1.1.3.1<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependencies</span>&gt;</span></span><br></pre></td></tr></table></figure>

<ul>
<li>maven过滤证书转码</li>
</ul>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">build</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">plugins</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.apache.maven.plugins<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>maven-resources-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">encoding</span>&gt;</span>UTF-8<span class="tag">&lt;/<span class="name">encoding</span>&gt;</span></span><br><span class="line">                <span class="comment">&lt;!-- 过滤后缀为p12/crt/pem/pfx不需要转码的证书文件 --&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">nonFilteredFileExtensions</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;<span class="name">nonFilteredFileExtension</span>&gt;</span>p12<span class="tag">&lt;/<span class="name">nonFilteredFileExtension</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;<span class="name">nonFilteredFileExtension</span>&gt;</span>crt<span class="tag">&lt;/<span class="name">nonFilteredFileExtension</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;<span class="name">nonFilteredFileExtension</span>&gt;</span>pem<span class="tag">&lt;/<span class="name">nonFilteredFileExtension</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;<span class="name">nonFilteredFileExtension</span>&gt;</span>pfx<span class="tag">&lt;/<span class="name">nonFilteredFileExtension</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;/<span class="name">nonFilteredFileExtensions</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">plugins</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">build</span>&gt;</span></span><br></pre></td></tr></table></figure>
<ul>
<li>将下载好的证书放在 <code>src/main/resources</code></li>
</ul>
<h2 id="代码实现"><a href="#代码实现" class="headerlink" title="代码实现"></a>代码实现</h2><ul>
<li>HttpUtils（企业付款http请求工具）</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> com.zero.aliatry.utils.withdrawal;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> org.apache.http.NameValuePair;</span><br><span class="line"><span class="keyword">import</span> org.apache.http.client.config.RequestConfig;</span><br><span class="line"><span class="keyword">import</span> org.apache.http.client.entity.UrlEncodedFormEntity;</span><br><span class="line"><span class="keyword">import</span> org.apache.http.client.methods.CloseableHttpResponse;</span><br><span class="line"><span class="keyword">import</span> org.apache.http.client.methods.HttpGet;</span><br><span class="line"><span class="keyword">import</span> org.apache.http.client.methods.HttpPost;</span><br><span class="line"><span class="keyword">import</span> org.apache.http.conn.ssl.SSLConnectionSocketFactory;</span><br><span class="line"><span class="keyword">import</span> org.apache.http.entity.StringEntity;</span><br><span class="line"><span class="keyword">import</span> org.apache.http.impl.client.CloseableHttpClient;</span><br><span class="line"><span class="keyword">import</span> org.apache.http.impl.client.HttpClients;</span><br><span class="line"><span class="keyword">import</span> org.apache.http.message.BasicNameValuePair;</span><br><span class="line"><span class="keyword">import</span> org.apache.http.ssl.SSLContexts;</span><br><span class="line"><span class="keyword">import</span> org.apache.http.util.EntityUtils;</span><br><span class="line"><span class="keyword">import</span> org.springframework.core.io.ClassPathResource;</span><br><span class="line"><span class="keyword">import</span> org.springframework.core.io.Resource;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> javax.net.ssl.SSLContext;</span><br><span class="line"><span class="keyword">import</span> java.io.IOException;</span><br><span class="line"><span class="keyword">import</span> java.io.UnsupportedEncodingException;</span><br><span class="line"><span class="keyword">import</span> java.net.URLEncoder;</span><br><span class="line"><span class="keyword">import</span> java.security.KeyStore;</span><br><span class="line"><span class="keyword">import</span> java.util.ArrayList;</span><br><span class="line"><span class="keyword">import</span> java.util.List;</span><br><span class="line"><span class="keyword">import</span> java.util.Map;</span><br><span class="line"><span class="keyword">import</span> java.util.Map.Entry;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 企业付款http请求工具</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">HttpUtils</span> &#123;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="type">String</span> <span class="variable">DEFAULT_CHARSET</span> <span class="operator">=</span> <span class="string">&quot;UTF-8&quot;</span>;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="type">int</span> <span class="variable">CONNECT_TIME_OUT</span> <span class="operator">=</span> <span class="number">5000</span>; <span class="comment">//链接超时时间3秒</span></span><br><span class="line"></span><br><span class="line">	<span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="type">RequestConfig</span> <span class="variable">REQUEST_CONFIG</span> <span class="operator">=</span> RequestConfig.custom().setConnectTimeout(CONNECT_TIME_OUT).build();</span><br><span class="line"></span><br><span class="line">	<span class="keyword">private</span> <span class="keyword">static</span> <span class="type">SSLContext</span> <span class="variable">wx_ssl_context</span> <span class="operator">=</span> <span class="literal">null</span>; <span class="comment">//微信支付ssl证书</span></span><br><span class="line"></span><br><span class="line">	<span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="type">String</span> <span class="variable">MCH_ID</span>  <span class="operator">=</span> <span class="string">&quot;1000000000&quot;</span>;<span class="comment">//证书密码默认是商户号</span></span><br><span class="line"></span><br><span class="line">	<span class="keyword">static</span>&#123;</span><br><span class="line">		<span class="type">Resource</span> <span class="variable">resource</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">ClassPathResource</span>(<span class="string">&quot;apiclient_cert.p12&quot;</span>);<span class="comment">//该证书名字最好改为别人猜不到的</span></span><br><span class="line">		<span class="keyword">try</span> &#123;</span><br><span class="line">			<span class="type">KeyStore</span> <span class="variable">keystore</span> <span class="operator">=</span> KeyStore.getInstance(<span class="string">&quot;PKCS12&quot;</span>);</span><br><span class="line">			<span class="type">char</span>[] keyPassword = MCH_ID.toCharArray(); <span class="comment">//证书密码</span></span><br><span class="line">			keystore.load(resource.getInputStream(), keyPassword);</span><br><span class="line">			wx_ssl_context = SSLContexts.custom().loadKeyMaterial(keystore, keyPassword).build();</span><br><span class="line">		&#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">			e.printStackTrace();</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@description</span> 功能描述: get 请求</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> url 请求地址</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> params 参数</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> headers headers参数</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@return</span> 请求失败返回null</span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> String <span class="title function_">get</span><span class="params">(String url, Map&lt;String, String&gt; params, Map&lt;String, String&gt; headers)</span> &#123;</span><br><span class="line"></span><br><span class="line">		<span class="type">CloseableHttpClient</span> <span class="variable">httpClient</span> <span class="operator">=</span> <span class="literal">null</span>;</span><br><span class="line">		<span class="keyword">if</span> (params != <span class="literal">null</span> &amp;&amp; !params.isEmpty()) &#123;</span><br><span class="line">			<span class="type">StringBuffer</span> <span class="variable">param</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">StringBuffer</span>();</span><br><span class="line">			<span class="type">boolean</span> <span class="variable">flag</span> <span class="operator">=</span> <span class="literal">true</span>; <span class="comment">// 是否开始</span></span><br><span class="line">			<span class="keyword">for</span> (Entry&lt;String, String&gt; entry : params.entrySet()) &#123;</span><br><span class="line">				<span class="keyword">if</span> (flag) &#123;</span><br><span class="line">					param.append(<span class="string">&quot;?&quot;</span>);</span><br><span class="line">					flag = <span class="literal">false</span>;</span><br><span class="line">				&#125; <span class="keyword">else</span> &#123;</span><br><span class="line">					param.append(<span class="string">&quot;&amp;&quot;</span>);</span><br><span class="line">				&#125;</span><br><span class="line">				param.append(entry.getKey()).append(<span class="string">&quot;=&quot;</span>);</span><br><span class="line"></span><br><span class="line">				<span class="keyword">try</span> &#123;</span><br><span class="line">					param.append(URLEncoder.encode(entry.getValue(), DEFAULT_CHARSET));</span><br><span class="line">				&#125; <span class="keyword">catch</span> (UnsupportedEncodingException e) &#123;</span><br><span class="line">					<span class="comment">//编码失败</span></span><br><span class="line">				&#125;</span><br><span class="line">			&#125;</span><br><span class="line">			url += param.toString();</span><br><span class="line">		&#125;</span><br><span class="line"></span><br><span class="line">		<span class="type">String</span> <span class="variable">body</span> <span class="operator">=</span> <span class="literal">null</span>;</span><br><span class="line">		<span class="type">CloseableHttpResponse</span> <span class="variable">response</span> <span class="operator">=</span> <span class="literal">null</span>;</span><br><span class="line">		<span class="keyword">try</span> &#123;</span><br><span class="line">			httpClient = HttpClients.custom().setDefaultRequestConfig(REQUEST_CONFIG).build();</span><br><span class="line">			<span class="type">HttpGet</span> <span class="variable">httpGet</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">HttpGet</span>(url);</span><br><span class="line">			response = httpClient.execute(httpGet);</span><br><span class="line">			body = EntityUtils.toString(response.getEntity(), DEFAULT_CHARSET);</span><br><span class="line">		&#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">			e.printStackTrace();</span><br><span class="line">		&#125; <span class="keyword">finally</span> &#123;</span><br><span class="line">			<span class="keyword">if</span> (response != <span class="literal">null</span>) &#123;</span><br><span class="line">				<span class="keyword">try</span> &#123;</span><br><span class="line">					response.close();</span><br><span class="line">				&#125; <span class="keyword">catch</span> (IOException e) &#123;</span><br><span class="line">					e.printStackTrace();</span><br><span class="line">				&#125;</span><br><span class="line">			&#125;</span><br><span class="line"></span><br><span class="line">			<span class="keyword">if</span> (httpClient != <span class="literal">null</span>) &#123;</span><br><span class="line">				<span class="keyword">try</span> &#123;</span><br><span class="line">					httpClient.close();</span><br><span class="line">				&#125; <span class="keyword">catch</span> (IOException e) &#123;</span><br><span class="line">					e.printStackTrace();</span><br><span class="line">				&#125;</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">return</span> body;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@description</span> 功能描述: get 请求</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> url 请求地址</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@return</span> 请求失败返回null</span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> String <span class="title function_">get</span><span class="params">(String url)</span> &#123;</span><br><span class="line">		<span class="keyword">return</span> get(url, <span class="literal">null</span>);</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@description</span> 功能描述: get 请求</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> url 请求地址</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> params 参数</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@return</span> 请求失败返回null</span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> String <span class="title function_">get</span><span class="params">(String url, Map&lt;String, String&gt; params)</span> &#123;</span><br><span class="line">		<span class="keyword">return</span> get(url, params, <span class="literal">null</span>);</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@description</span> 功能描述: post 请求</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> url 请求地址</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> params 参数</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@return</span> 请求失败返回null</span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> String <span class="title function_">post</span><span class="params">(String url, Map&lt;String, String&gt; params)</span> &#123;</span><br><span class="line">		<span class="type">CloseableHttpClient</span> <span class="variable">httpClient</span> <span class="operator">=</span> <span class="literal">null</span>;</span><br><span class="line">		<span class="type">HttpPost</span> <span class="variable">httpPost</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">HttpPost</span>(url);</span><br><span class="line">		List&lt;NameValuePair&gt; nameValuePairs = <span class="keyword">new</span> <span class="title class_">ArrayList</span>&lt;&gt;();</span><br><span class="line">		<span class="keyword">if</span> (params != <span class="literal">null</span> &amp;&amp; !params.isEmpty()) &#123;</span><br><span class="line">			<span class="keyword">for</span> (Entry&lt;String, String&gt; entry : params.entrySet()) &#123;</span><br><span class="line">				nameValuePairs.add(<span class="keyword">new</span> <span class="title class_">BasicNameValuePair</span>(entry.getKey(), entry.getValue()));</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line"></span><br><span class="line">		<span class="type">String</span> <span class="variable">body</span> <span class="operator">=</span> <span class="literal">null</span>;</span><br><span class="line">		<span class="type">CloseableHttpResponse</span> <span class="variable">response</span> <span class="operator">=</span> <span class="literal">null</span>;</span><br><span class="line">		<span class="keyword">try</span> &#123;</span><br><span class="line">			httpClient = HttpClients.custom().setDefaultRequestConfig(REQUEST_CONFIG).build();</span><br><span class="line">			httpPost.setEntity(<span class="keyword">new</span> <span class="title class_">UrlEncodedFormEntity</span>(nameValuePairs, DEFAULT_CHARSET));</span><br><span class="line">			response = httpClient.execute(httpPost);</span><br><span class="line">			body = EntityUtils.toString(response.getEntity(), DEFAULT_CHARSET);</span><br><span class="line">		&#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">			e.printStackTrace();</span><br><span class="line">		&#125; <span class="keyword">finally</span> &#123;</span><br><span class="line">			<span class="keyword">if</span> (response != <span class="literal">null</span>) &#123;</span><br><span class="line">				<span class="keyword">try</span> &#123;</span><br><span class="line">					response.close();</span><br><span class="line">				&#125; <span class="keyword">catch</span> (IOException e) &#123;</span><br><span class="line">					e.printStackTrace();</span><br><span class="line">				&#125;</span><br><span class="line">			&#125;</span><br><span class="line"></span><br><span class="line">			<span class="keyword">if</span> (httpClient != <span class="literal">null</span>) &#123;</span><br><span class="line">				<span class="keyword">try</span> &#123;</span><br><span class="line">					httpClient.close();</span><br><span class="line">				&#125; <span class="keyword">catch</span> (IOException e) &#123;</span><br><span class="line">					e.printStackTrace();</span><br><span class="line">				&#125;</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">return</span> body;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@description</span> 功能描述: post 请求</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> url 请求地址</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> s 参数xml</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@return</span> 请求失败返回null</span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> String <span class="title function_">post</span><span class="params">(String url, String s)</span> &#123;</span><br><span class="line">		<span class="type">CloseableHttpClient</span> <span class="variable">httpClient</span> <span class="operator">=</span> <span class="literal">null</span>;</span><br><span class="line">		<span class="type">HttpPost</span> <span class="variable">httpPost</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">HttpPost</span>(url);</span><br><span class="line">		<span class="type">String</span> <span class="variable">body</span> <span class="operator">=</span> <span class="literal">null</span>;</span><br><span class="line">		<span class="type">CloseableHttpResponse</span> <span class="variable">response</span> <span class="operator">=</span> <span class="literal">null</span>;</span><br><span class="line">		<span class="keyword">try</span> &#123;</span><br><span class="line">			httpClient = HttpClients.custom().setDefaultRequestConfig(REQUEST_CONFIG).build();</span><br><span class="line">			httpPost.setEntity(<span class="keyword">new</span> <span class="title class_">StringEntity</span>(s, DEFAULT_CHARSET));</span><br><span class="line">			response = httpClient.execute(httpPost);</span><br><span class="line">			body = EntityUtils.toString(response.getEntity(), DEFAULT_CHARSET);</span><br><span class="line">		&#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">			e.printStackTrace();</span><br><span class="line">		&#125; <span class="keyword">finally</span> &#123;</span><br><span class="line">			<span class="keyword">if</span> (response != <span class="literal">null</span>) &#123;</span><br><span class="line">				<span class="keyword">try</span> &#123;</span><br><span class="line">					response.close();</span><br><span class="line">				&#125; <span class="keyword">catch</span> (IOException e) &#123;</span><br><span class="line">					e.printStackTrace();</span><br><span class="line">				&#125;</span><br><span class="line">			&#125;</span><br><span class="line"></span><br><span class="line">			<span class="keyword">if</span> (httpClient != <span class="literal">null</span>) &#123;</span><br><span class="line">				<span class="keyword">try</span> &#123;</span><br><span class="line">					httpClient.close();</span><br><span class="line">				&#125; <span class="keyword">catch</span> (IOException e) &#123;</span><br><span class="line">					e.printStackTrace();</span><br><span class="line">				&#125;</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">return</span> body;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@description</span> 功能描述: post https请求，服务器双向证书验证</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> url 请求地址</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> params 参数</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@return</span> 请求失败返回null</span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	 <span class="keyword">public</span> <span class="keyword">static</span> String <span class="title function_">posts</span><span class="params">(String url, Map&lt;String, String&gt; params)</span> &#123;</span><br><span class="line">		<span class="type">CloseableHttpClient</span> <span class="variable">httpClient</span> <span class="operator">=</span> <span class="literal">null</span>;</span><br><span class="line">		<span class="type">HttpPost</span> <span class="variable">httpPost</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">HttpPost</span>(url);</span><br><span class="line">		List&lt;NameValuePair&gt; nameValuePairs = <span class="keyword">new</span> <span class="title class_">ArrayList</span>&lt;&gt;();</span><br><span class="line">		<span class="keyword">if</span> (params != <span class="literal">null</span> &amp;&amp; !params.isEmpty()) &#123;</span><br><span class="line">			<span class="keyword">for</span> (Entry&lt;String, String&gt; entry : params.entrySet()) &#123;</span><br><span class="line">				nameValuePairs.add(<span class="keyword">new</span> <span class="title class_">BasicNameValuePair</span>(entry.getKey(), entry.getValue()));</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line"></span><br><span class="line">		<span class="type">String</span> <span class="variable">body</span> <span class="operator">=</span> <span class="literal">null</span>;</span><br><span class="line">		<span class="type">CloseableHttpResponse</span> <span class="variable">response</span> <span class="operator">=</span> <span class="literal">null</span>;</span><br><span class="line">		<span class="keyword">try</span> &#123;</span><br><span class="line">			httpClient = HttpClients.custom().setDefaultRequestConfig(REQUEST_CONFIG).setSSLSocketFactory(getSSLConnectionSocket()).build();</span><br><span class="line">			httpPost.setEntity(<span class="keyword">new</span> <span class="title class_">UrlEncodedFormEntity</span>(nameValuePairs, DEFAULT_CHARSET));</span><br><span class="line">			response = httpClient.execute(httpPost);</span><br><span class="line">			body = EntityUtils.toString(response.getEntity(), DEFAULT_CHARSET);</span><br><span class="line">		&#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">			e.printStackTrace();</span><br><span class="line">		&#125; <span class="keyword">finally</span> &#123;</span><br><span class="line">			<span class="keyword">if</span> (response != <span class="literal">null</span>) &#123;</span><br><span class="line">				<span class="keyword">try</span> &#123;</span><br><span class="line">					response.close();</span><br><span class="line">				&#125; <span class="keyword">catch</span> (IOException e) &#123;</span><br><span class="line">					e.printStackTrace();</span><br><span class="line">				&#125;</span><br><span class="line">			&#125;</span><br><span class="line"></span><br><span class="line">			<span class="keyword">if</span> (httpClient != <span class="literal">null</span>) &#123;</span><br><span class="line">				<span class="keyword">try</span> &#123;</span><br><span class="line">					httpClient.close();</span><br><span class="line">				&#125; <span class="keyword">catch</span> (IOException e) &#123;</span><br><span class="line">					e.printStackTrace();</span><br><span class="line">				&#125;</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">return</span> body;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@description</span> 功能描述: post https请求，服务器双向证书验证</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> url 请求地址</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> s 参数xml</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@return</span> 请求失败返回null</span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> String <span class="title function_">posts</span><span class="params">(String url, String s)</span> &#123;</span><br><span class="line">		<span class="type">CloseableHttpClient</span> <span class="variable">httpClient</span> <span class="operator">=</span> <span class="literal">null</span>;</span><br><span class="line">		<span class="type">HttpPost</span> <span class="variable">httpPost</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">HttpPost</span>(url);</span><br><span class="line">		<span class="type">String</span> <span class="variable">body</span> <span class="operator">=</span> <span class="literal">null</span>;</span><br><span class="line">		<span class="type">CloseableHttpResponse</span> <span class="variable">response</span> <span class="operator">=</span> <span class="literal">null</span>;</span><br><span class="line">		<span class="keyword">try</span> &#123;</span><br><span class="line">			httpClient = HttpClients.custom().setDefaultRequestConfig(REQUEST_CONFIG).setSSLSocketFactory(getSSLConnectionSocket()).build();</span><br><span class="line">			httpPost.setEntity(<span class="keyword">new</span> <span class="title class_">StringEntity</span>(s, DEFAULT_CHARSET));</span><br><span class="line">			response = httpClient.execute(httpPost);</span><br><span class="line">			body = EntityUtils.toString(response.getEntity(), DEFAULT_CHARSET);</span><br><span class="line">		&#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">			e.printStackTrace();</span><br><span class="line">		&#125; <span class="keyword">finally</span> &#123;</span><br><span class="line">			<span class="keyword">if</span> (response != <span class="literal">null</span>) &#123;</span><br><span class="line">				<span class="keyword">try</span> &#123;</span><br><span class="line">					response.close();</span><br><span class="line">				&#125; <span class="keyword">catch</span> (IOException e) &#123;</span><br><span class="line">					e.printStackTrace();</span><br><span class="line">				&#125;</span><br><span class="line">			&#125;</span><br><span class="line"></span><br><span class="line">			<span class="keyword">if</span> (httpClient != <span class="literal">null</span>) &#123;</span><br><span class="line">				<span class="keyword">try</span> &#123;</span><br><span class="line">					httpClient.close();</span><br><span class="line">				&#125; <span class="keyword">catch</span> (IOException e) &#123;</span><br><span class="line">					e.printStackTrace();</span><br><span class="line">				&#125;</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">return</span> body;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">//获取ssl connection链接</span></span><br><span class="line">	<span class="keyword">private</span> <span class="keyword">static</span> SSLConnectionSocketFactory <span class="title function_">getSSLConnectionSocket</span><span class="params">()</span> &#123;</span><br><span class="line">		<span class="keyword">return</span> <span class="keyword">new</span> <span class="title class_">SSLConnectionSocketFactory</span>(wx_ssl_context, <span class="keyword">new</span> <span class="title class_">String</span>[] &#123;<span class="string">&quot;TLSv1&quot;</span>, <span class="string">&quot;TLSv1.1&quot;</span>, <span class="string">&quot;TLSv1.2&quot;</span>&#125;, <span class="literal">null</span>, SSLConnectionSocketFactory.getDefaultHostnameVerifier());</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<ul>
<li>XmlUtil （xml、map转换工具）</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> com.zero.aliatry.utils.withdrawal;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> com.github.pagehelper.util.StringUtil;</span><br><span class="line"><span class="keyword">import</span> org.xmlpull.v1.XmlPullParser;</span><br><span class="line"><span class="keyword">import</span> org.xmlpull.v1.XmlPullParserException;</span><br><span class="line"><span class="keyword">import</span> org.xmlpull.v1.XmlPullParserFactory;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.io.ByteArrayInputStream;</span><br><span class="line"><span class="keyword">import</span> java.io.IOException;</span><br><span class="line"><span class="keyword">import</span> java.io.InputStream;</span><br><span class="line"><span class="keyword">import</span> java.util.HashMap;</span><br><span class="line"><span class="keyword">import</span> java.util.Map;</span><br><span class="line"><span class="keyword">import</span> java.util.Map.Entry;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * xml、map转换工具</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">XmlUtil</span> &#123;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="type">String</span> <span class="variable">PREFIX_XML</span> <span class="operator">=</span> <span class="string">&quot;&lt;xml&gt;&quot;</span>;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="type">String</span> <span class="variable">SUFFIX_XML</span> <span class="operator">=</span> <span class="string">&quot;&lt;/xml&gt;&quot;</span>;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="type">String</span> <span class="variable">PREFIX_CDATA</span> <span class="operator">=</span> <span class="string">&quot;&lt;![CDATA[&quot;</span>;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="type">String</span> <span class="variable">SUFFIX_CDATA</span> <span class="operator">=</span> <span class="string">&quot;]]&gt;&quot;</span>;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * 转化成xml, 单层无嵌套</span></span><br><span class="line"><span class="comment">	 *</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> parm</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> isAddCDATA</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> String <span class="title function_">xmlFormat</span><span class="params">(Map&lt;String, String&gt; parm, <span class="type">boolean</span> isAddCDATA)</span> &#123;</span><br><span class="line"></span><br><span class="line">		<span class="type">StringBuffer</span> <span class="variable">strbuff</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">StringBuffer</span>(PREFIX_XML);</span><br><span class="line">		<span class="keyword">if</span> (CollectionUtil.isNotEmpty(parm)) &#123;</span><br><span class="line">			<span class="keyword">for</span> (Entry&lt;String, String&gt; entry : parm.entrySet()) &#123;</span><br><span class="line">				strbuff.append(<span class="string">&quot;&lt;&quot;</span>).append(entry.getKey()).append(<span class="string">&quot;&gt;&quot;</span>);</span><br><span class="line">				<span class="keyword">if</span> (isAddCDATA) &#123;</span><br><span class="line">					strbuff.append(PREFIX_CDATA);</span><br><span class="line">					<span class="keyword">if</span> (StringUtil.isNotEmpty(entry.getValue())) &#123;</span><br><span class="line">						strbuff.append(entry.getValue());</span><br><span class="line">					&#125;</span><br><span class="line">					strbuff.append(SUFFIX_CDATA);</span><br><span class="line">				&#125; <span class="keyword">else</span> &#123;</span><br><span class="line">					<span class="keyword">if</span> (StringUtil.isNotEmpty(entry.getValue())) &#123;</span><br><span class="line">						strbuff.append(entry.getValue());</span><br><span class="line">					&#125;</span><br><span class="line">				&#125;</span><br><span class="line">				strbuff.append(<span class="string">&quot;&lt;/&quot;</span>).append(entry.getKey()).append(<span class="string">&quot;&gt;&quot;</span>);</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">return</span> strbuff.append(SUFFIX_XML).toString();</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * 解析xml</span></span><br><span class="line"><span class="comment">	 *</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> xml</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@throws</span> XmlPullParserException</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@throws</span> IOException</span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> Map&lt;String, String&gt; <span class="title function_">xmlParse</span><span class="params">(String xml)</span> <span class="keyword">throws</span> XmlPullParserException, IOException &#123;</span><br><span class="line">		Map&lt;String, String&gt; map = <span class="literal">null</span>;</span><br><span class="line">		<span class="keyword">if</span> (StringUtil.isNotEmpty(xml)) &#123;</span><br><span class="line">			<span class="type">InputStream</span> <span class="variable">inputStream</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">ByteArrayInputStream</span>(xml.getBytes());</span><br><span class="line">			<span class="type">XmlPullParser</span> <span class="variable">pullParser</span> <span class="operator">=</span> XmlPullParserFactory.newInstance().newPullParser();</span><br><span class="line">			pullParser.setInput(inputStream, <span class="string">&quot;UTF-8&quot;</span>); <span class="comment">// 为xml设置要解析的xml数据</span></span><br><span class="line">			<span class="type">int</span> <span class="variable">eventType</span> <span class="operator">=</span> pullParser.getEventType();</span><br><span class="line"></span><br><span class="line">			<span class="keyword">while</span> (eventType != XmlPullParser.END_DOCUMENT) &#123;</span><br><span class="line">				<span class="keyword">switch</span> (eventType) &#123;</span><br><span class="line">				<span class="keyword">case</span> XmlPullParser.START_DOCUMENT:</span><br><span class="line">					map = <span class="keyword">new</span> <span class="title class_">HashMap</span>&lt;String, String&gt;();</span><br><span class="line">					<span class="keyword">break</span>;</span><br><span class="line">				<span class="keyword">case</span> XmlPullParser.START_TAG:</span><br><span class="line">					<span class="type">String</span> <span class="variable">key</span> <span class="operator">=</span> pullParser.getName();</span><br><span class="line">					<span class="keyword">if</span> (key.equals(<span class="string">&quot;xml&quot;</span>))</span><br><span class="line">						<span class="keyword">break</span>;</span><br><span class="line">					<span class="type">String</span> <span class="variable">value</span> <span class="operator">=</span> pullParser.nextText().trim();</span><br><span class="line">					map.put(key, value);</span><br><span class="line">					<span class="keyword">break</span>;</span><br><span class="line">				<span class="keyword">case</span> XmlPullParser.END_TAG:</span><br><span class="line">					<span class="keyword">break</span>;</span><br><span class="line">				&#125;</span><br><span class="line">				eventType = pullParser.next();</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">return</span> map;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<ul>
<li>PayUtil</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> com.zero.aliatry.utils.withdrawal;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> com.github.pagehelper.util.StringUtil;</span><br><span class="line"><span class="keyword">import</span> com.zero.aliatry.utils.ChineseCharToEnUtil;</span><br><span class="line"><span class="keyword">import</span> com.zero.aliatry.utils.DateUtil;</span><br><span class="line"><span class="keyword">import</span> com.zero.aliatry.utils.Encrypt;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> javax.servlet.http.HttpServletRequest;</span><br><span class="line"><span class="keyword">import</span> java.io.UnsupportedEncodingException;</span><br><span class="line"><span class="keyword">import</span> java.net.URLEncoder;</span><br><span class="line"><span class="keyword">import</span> java.util.Arrays;</span><br><span class="line"><span class="keyword">import</span> java.util.Date;</span><br><span class="line"><span class="keyword">import</span> java.util.Map;</span><br><span class="line"><span class="keyword">import</span> java.util.Set;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">PayUtil</span> &#123;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * 生成订单号</span></span><br><span class="line"><span class="comment">	 *</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> String <span class="title function_">getTradeNo</span><span class="params">()</span> &#123;</span><br><span class="line">		<span class="comment">// 自增8位数 00000001</span></span><br><span class="line">		<span class="keyword">return</span> <span class="string">&quot;TNO&quot;</span> + DateUtil.formatDate(<span class="keyword">new</span> <span class="title class_">Date</span>(), DateUtil.TIME_STAMP_PATTERN) + <span class="string">&quot;00000001&quot;</span>;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * 退款单号</span></span><br><span class="line"><span class="comment">	 *</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> String <span class="title function_">getRefundNo</span><span class="params">()</span> &#123;</span><br><span class="line">		<span class="comment">// 自增8位数 00000001</span></span><br><span class="line">		<span class="keyword">return</span> <span class="string">&quot;RNO&quot;</span> + DateUtil.formatDate(<span class="keyword">new</span> <span class="title class_">Date</span>(), DateUtil.TIME_STAMP_PATTERN) + <span class="string">&quot;00000001&quot;</span>;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * 退款单号</span></span><br><span class="line"><span class="comment">	 *</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> String <span class="title function_">getTransferNo</span><span class="params">()</span> &#123;</span><br><span class="line">		<span class="comment">// 自增8位数 00000001</span></span><br><span class="line">		<span class="keyword">return</span> <span class="string">&quot;TNO&quot;</span> + DateUtil.formatDate(<span class="keyword">new</span> <span class="title class_">Date</span>(), DateUtil.TIME_STAMP_PATTERN) + <span class="string">&quot;00000001&quot;</span>;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * 返回客户端ip</span></span><br><span class="line"><span class="comment">	 *</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> request</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> String <span class="title function_">getRemoteAddrIp</span><span class="params">(HttpServletRequest request)</span> &#123;</span><br><span class="line">		<span class="type">String</span> <span class="variable">ip</span> <span class="operator">=</span> request.getHeader(<span class="string">&quot;X-Forwarded-For&quot;</span>);</span><br><span class="line">		<span class="keyword">if</span> (StringUtil.isNotEmpty(ip) &amp;&amp; !<span class="string">&quot;unKnown&quot;</span>.equalsIgnoreCase(ip)) &#123;</span><br><span class="line">			<span class="comment">// 多次反向代理后会有多个ip值，第一个ip才是真实ip</span></span><br><span class="line">			<span class="type">int</span> <span class="variable">index</span> <span class="operator">=</span> ip.indexOf(<span class="string">&quot;,&quot;</span>);</span><br><span class="line">			<span class="keyword">if</span> (index != -<span class="number">1</span>) &#123;</span><br><span class="line">				<span class="keyword">return</span> ip.substring(<span class="number">0</span>, index);</span><br><span class="line">			&#125; <span class="keyword">else</span> &#123;</span><br><span class="line">				<span class="keyword">return</span> ip;</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">		ip = request.getHeader(<span class="string">&quot;X-Real-IP&quot;</span>);</span><br><span class="line">		<span class="keyword">if</span> (StringUtil.isNotEmpty(ip) &amp;&amp; !<span class="string">&quot;unKnown&quot;</span>.equalsIgnoreCase(ip)) &#123;</span><br><span class="line">			<span class="keyword">return</span> ip;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">return</span> request.getRemoteAddr();</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * 获取服务器的ip地址</span></span><br><span class="line"><span class="comment">	 *</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> request</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> String <span class="title function_">getLocalIp</span><span class="params">(HttpServletRequest request)</span> &#123;</span><br><span class="line">		<span class="keyword">return</span> request.getLocalAddr();</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> String <span class="title function_">getSign</span><span class="params">(Map&lt;String, String&gt; params, String paternerKey)</span> <span class="keyword">throws</span> UnsupportedEncodingException &#123;</span><br><span class="line">		<span class="keyword">return</span> Encrypt.getMD5(createSign(params, <span class="literal">false</span>) + <span class="string">&quot;&amp;key=&quot;</span> + paternerKey).toUpperCase();</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * 构造签名</span></span><br><span class="line"><span class="comment">	 *</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> params</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@param</span> encode</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@throws</span> UnsupportedEncodingException</span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> String <span class="title function_">createSign</span><span class="params">(Map&lt;String, String&gt; params, <span class="type">boolean</span> encode)</span> <span class="keyword">throws</span> UnsupportedEncodingException &#123;</span><br><span class="line">		Set&lt;String&gt; keysSet = params.keySet();</span><br><span class="line">		Object[] keys = keysSet.toArray();</span><br><span class="line">		Arrays.sort(keys);</span><br><span class="line">		<span class="type">StringBuffer</span> <span class="variable">temp</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">StringBuffer</span>();</span><br><span class="line">		<span class="type">boolean</span> <span class="variable">first</span> <span class="operator">=</span> <span class="literal">true</span>;</span><br><span class="line">		<span class="keyword">for</span> (Object key : keys) &#123;</span><br><span class="line">			<span class="keyword">if</span> (key == <span class="literal">null</span> || StringUtil.isEmpty(params.get(key))) <span class="comment">// 参数为空不参与签名</span></span><br><span class="line">				<span class="keyword">continue</span>;</span><br><span class="line">			<span class="keyword">if</span> (first) &#123;</span><br><span class="line">				first = <span class="literal">false</span>;</span><br><span class="line">			&#125; <span class="keyword">else</span> &#123;</span><br><span class="line">				temp.append(<span class="string">&quot;&amp;&quot;</span>);</span><br><span class="line">			&#125;</span><br><span class="line">			temp.append(key).append(<span class="string">&quot;=&quot;</span>);</span><br><span class="line">			<span class="type">Object</span> <span class="variable">value</span> <span class="operator">=</span> params.get(key);</span><br><span class="line">			<span class="type">String</span> <span class="variable">valueStr</span> <span class="operator">=</span> <span class="string">&quot;&quot;</span>;</span><br><span class="line">			<span class="keyword">if</span> (<span class="literal">null</span> != value) &#123;</span><br><span class="line">				valueStr = value.toString();</span><br><span class="line">			&#125;</span><br><span class="line">			<span class="keyword">if</span> (encode) &#123;</span><br><span class="line">				temp.append(URLEncoder.encode(valueStr, <span class="string">&quot;UTF-8&quot;</span>));</span><br><span class="line">			&#125; <span class="keyword">else</span> &#123;</span><br><span class="line">				temp.append(valueStr);</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">return</span> temp.toString();</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * 创建支付随机字符串</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> String <span class="title function_">getNonceStr</span><span class="params">()</span>&#123;</span><br><span class="line">		<span class="keyword">return</span> ChineseCharToEnUtil.randomString(ChineseCharToEnUtil.LETTER_NUMBER_CHAR, <span class="number">32</span>);</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/**</span></span><br><span class="line"><span class="comment">	 * 支付时间戳</span></span><br><span class="line"><span class="comment">	 * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">	 */</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> String <span class="title function_">payTimestamp</span><span class="params">()</span> &#123;</span><br><span class="line">		<span class="keyword">return</span> Long.toString(System.currentTimeMillis() / <span class="number">1000</span>);</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<ul>
<li>CollectionUtil</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> com.zero.aliatry.utils.withdrawal;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.util.ArrayList;</span><br><span class="line"><span class="keyword">import</span> java.util.Collection;</span><br><span class="line"><span class="keyword">import</span> java.util.List;</span><br><span class="line"><span class="keyword">import</span> java.util.Map;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 集合类工具</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">CollectionUtil</span> &#123;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">private</span> <span class="title function_">CollectionUtil</span><span class="params">()</span> &#123;</span><br><span class="line">		<span class="built_in">super</span>();</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">// 判断一个集合是否为空</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> &lt;T&gt; <span class="type">boolean</span> <span class="title function_">isEmpty</span><span class="params">(Collection&lt;T&gt; col)</span> &#123;</span><br><span class="line">		<span class="keyword">if</span> (col == <span class="literal">null</span> || col.isEmpty()) &#123;</span><br><span class="line">			<span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">		&#125;</span><br><span class="line"></span><br><span class="line">		<span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">// 判断一个集合是否不为空</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> &lt;T&gt; <span class="type">boolean</span> <span class="title function_">isNotEmpty</span><span class="params">(Collection&lt;T&gt; col)</span> &#123;</span><br><span class="line">		<span class="keyword">return</span> !isEmpty(col);</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">// 判断Map是否为空</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> &lt;K, V&gt; <span class="type">boolean</span> <span class="title function_">isEmpty</span><span class="params">(Map&lt;K, V&gt; map)</span> &#123;</span><br><span class="line">		<span class="keyword">if</span> (map == <span class="literal">null</span> || map.isEmpty()) &#123;</span><br><span class="line">			<span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">		&#125;</span><br><span class="line"></span><br><span class="line">		<span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">// 判断Map是否不为空为空</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> &lt;K, V&gt; <span class="type">boolean</span> <span class="title function_">isNotEmpty</span><span class="params">(Map&lt;K, V&gt; map)</span> &#123;</span><br><span class="line">		<span class="keyword">return</span> !isEmpty(map);</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">// 去除list中的重复数据</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> &lt;T&gt; List&lt;T&gt; <span class="title function_">removeRepeat</span><span class="params">(List&lt;T&gt; list)</span> &#123;</span><br><span class="line">		<span class="keyword">if</span> (isEmpty(list)) &#123;</span><br><span class="line">			<span class="keyword">return</span> list;</span><br><span class="line">		&#125;</span><br><span class="line"></span><br><span class="line">		List&lt;T&gt; result = <span class="keyword">new</span> <span class="title class_">ArrayList</span>&lt;T&gt;();</span><br><span class="line">		<span class="keyword">for</span> (T e : list) &#123;</span><br><span class="line">			<span class="keyword">if</span> (!result.contains(e)) &#123;</span><br><span class="line">				result.add(e);</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line"></span><br><span class="line">		<span class="keyword">return</span> result;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="comment">// 将集合转换为String数组</span></span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> &lt;T&gt; String[] toArray(List&lt;T&gt; list) &#123;</span><br><span class="line">		<span class="keyword">if</span> (isEmpty(list)) &#123;</span><br><span class="line">			<span class="keyword">return</span> <span class="literal">null</span>;</span><br><span class="line">		&#125;</span><br><span class="line"></span><br><span class="line">		String[] result = <span class="keyword">new</span> <span class="title class_">String</span>[list.size()];</span><br><span class="line">		<span class="keyword">for</span> (<span class="type">int</span> <span class="variable">i</span> <span class="operator">=</span> <span class="number">0</span>; i &lt; list.size(); i++) &#123;</span><br><span class="line">			result[i] = String.valueOf(list.get(i));</span><br><span class="line">		&#125;</span><br><span class="line"></span><br><span class="line">		<span class="keyword">return</span> result;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<ul>
<li>TransferController（提现相关接口）</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> com.zero.aliatry.controller;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> com.alibaba.fastjson.JSONObject;</span><br><span class="line"><span class="keyword">import</span> com.github.pagehelper.util.StringUtil;</span><br><span class="line"><span class="keyword">import</span> com.zero.aliatry.entity.WithdrawalRecord;</span><br><span class="line"><span class="keyword">import</span> com.zero.aliatry.service.WithdrawalRecord.WithdrawalRecordService;</span><br><span class="line"><span class="keyword">import</span> com.zero.aliatry.service.appUser.AppUserService;</span><br><span class="line"><span class="keyword">import</span> com.zero.aliatry.service.sysUser.SysUserService;</span><br><span class="line"><span class="keyword">import</span> com.zero.aliatry.utils.CheckParamsUtil;</span><br><span class="line"><span class="keyword">import</span> com.zero.aliatry.utils.DateUtil;</span><br><span class="line"><span class="keyword">import</span> com.zero.aliatry.utils.IpAddrUtil;</span><br><span class="line"><span class="keyword">import</span> com.zero.aliatry.utils.exception.ErrorEnum;</span><br><span class="line"><span class="keyword">import</span> com.zero.aliatry.utils.exception.Result;</span><br><span class="line"><span class="keyword">import</span> com.zero.aliatry.utils.exception.ResultUtil;</span><br><span class="line"><span class="keyword">import</span> com.zero.aliatry.utils.withdrawal.CollectionUtil;</span><br><span class="line"><span class="keyword">import</span> com.zero.aliatry.utils.withdrawal.HttpUtils;</span><br><span class="line"><span class="keyword">import</span> com.zero.aliatry.utils.withdrawal.PayUtil;</span><br><span class="line"><span class="keyword">import</span> com.zero.aliatry.utils.withdrawal.XmlUtil;</span><br><span class="line"><span class="keyword">import</span> org.slf4j.Logger;</span><br><span class="line"><span class="keyword">import</span> org.slf4j.LoggerFactory;</span><br><span class="line"><span class="keyword">import</span> org.springframework.beans.factory.annotation.Autowired;</span><br><span class="line"><span class="keyword">import</span> org.springframework.transaction.annotation.Transactional;</span><br><span class="line"><span class="keyword">import</span> org.springframework.web.bind.annotation.*;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> javax.servlet.http.HttpServletRequest;</span><br><span class="line"><span class="keyword">import</span> javax.servlet.http.HttpServletResponse;</span><br><span class="line"><span class="keyword">import</span> java.util.HashMap;</span><br><span class="line"><span class="keyword">import</span> java.util.List;</span><br><span class="line"><span class="keyword">import</span> java.util.Map;</span><br><span class="line"><span class="keyword">import</span> java.util.UUID;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 提现相关接口</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="meta">@RestController</span></span><br><span class="line"><span class="meta">@RequestMapping(&quot;/transfer&quot;)</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">TransferController</span> &#123;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Autowired</span></span><br><span class="line">    SysUserService sysUserService;</span><br><span class="line">    <span class="meta">@Autowired</span></span><br><span class="line">    AppUserService appUserService;</span><br><span class="line">    <span class="meta">@Autowired</span></span><br><span class="line">    WithdrawalRecordService withdrawalRecordService;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="type">Logger</span> <span class="variable">logger</span> <span class="operator">=</span> LoggerFactory.getLogger(TransferController.class);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="type">String</span> <span class="variable">TRANSFERS_PAY</span> <span class="operator">=</span> <span class="string">&quot;https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers&quot;</span>; <span class="comment">// 企业付款API</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="type">String</span> <span class="variable">TRANSFERS_PAY_QUERY</span> <span class="operator">=</span> <span class="string">&quot;https://api.mch.weixin.qq.com/mmpaymkttransfers/gettransferinfo&quot;</span>; <span class="comment">// 企业付款查询API</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="type">String</span> <span class="variable">APP_ID</span> <span class="operator">=</span> <span class="string">&quot;APP_ID&quot;</span>  ;<span class="comment">//公众账号appid</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="type">String</span> <span class="variable">MCH_ID</span> <span class="operator">=</span> <span class="string">&quot;MCH_ID&quot;</span>;<span class="comment">//商户号</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="type">String</span> <span class="variable">API_SECRET</span> <span class="operator">=</span> <span class="string">&quot;API_SECRET&quot;</span>;<span class="comment">//API密钥</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 企业向个人支付转账</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> request</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> params</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="meta">@PostMapping(value = &quot;/pay&quot;)</span></span><br><span class="line">    <span class="meta">@ResponseBody</span></span><br><span class="line">    <span class="meta">@Transactional</span></span><br><span class="line">    <span class="keyword">public</span> Result <span class="title function_">transferPay</span><span class="params">(<span class="meta">@RequestBody</span> String params,HttpServletRequest request)</span> &#123;</span><br><span class="line"></span><br><span class="line">        <span class="comment">/** =============================================接口参数校验================================================*/</span></span><br><span class="line">        <span class="type">JSONObject</span> <span class="variable">jsonObject</span> <span class="operator">=</span> JSONObject.parseObject(params);<span class="comment">//解析json</span></span><br><span class="line">        <span class="comment">//校验参数是否为空</span></span><br><span class="line">        <span class="keyword">if</span>(CheckParamsUtil.isBlank(jsonObject,<span class="string">&quot;userId&quot;</span>,<span class="string">&quot;amount&quot;</span>,<span class="string">&quot;userType&quot;</span>))&#123;</span><br><span class="line">            <span class="keyword">return</span> ResultUtil.fail(ErrorEnum.ERROR_PARAM_ISBLANK);</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="comment">/**==============================================设置局部变量=================================================*/</span></span><br><span class="line">        <span class="type">String</span> <span class="variable">userId</span> <span class="operator">=</span> jsonObject.getString(<span class="string">&quot;userId&quot;</span>);<span class="comment">//用户id</span></span><br><span class="line">        <span class="type">String</span> <span class="variable">openid</span> <span class="operator">=</span> <span class="string">&quot;&quot;</span>;<span class="comment">//用户openid</span></span><br><span class="line">        <span class="type">Float</span> <span class="variable">applyMoney</span> <span class="operator">=</span> jsonObject.getFloat(<span class="string">&quot;amount&quot;</span>);<span class="comment">//用户申请提现金额 0.3-5000</span></span><br><span class="line">        <span class="type">int</span> <span class="variable">userType</span> <span class="operator">=</span> jsonObject.getInteger(<span class="string">&quot;userType&quot;</span>);<span class="comment">//用户类型</span></span><br><span class="line">        String amount;<span class="comment">//企业付款金额</span></span><br><span class="line">        <span class="type">Float</span> <span class="variable">poundage</span> <span class="operator">=</span> <span class="number">0f</span>;<span class="comment">//手续费</span></span><br><span class="line">        String desc;<span class="comment">//企业付款描述信息</span></span><br><span class="line">        <span class="type">String</span> <span class="variable">id</span> <span class="operator">=</span> UUID.randomUUID().toString().replaceAll(<span class="string">&quot;-&quot;</span>, <span class="string">&quot;&quot;</span>);<span class="comment">//提现记录表id</span></span><br><span class="line"></span><br><span class="line">        <span class="keyword">if</span>(applyMoney&lt;<span class="number">0.3</span>||applyMoney&gt;<span class="number">5000</span>)&#123;</span><br><span class="line">            <span class="keyword">return</span> ResultUtil.fail(<span class="string">&quot;00000001&quot;</span>,<span class="string">&quot;申请提现金额不符:低于最小金额0.30元或高于5000.00元&quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="comment">/** ======================================业务判断 1.userId是否有收款资格=====================================*/</span></span><br><span class="line">        <span class="keyword">if</span>(userType == <span class="number">1</span>)&#123;</span><br><span class="line">            openid = sysUserService.getOpenidBySysUserId(userId);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span>(userType == <span class="number">2</span>)&#123;</span><br><span class="line">            openid = appUserService.getOpenidByAppUserId(userId);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span>(openid==<span class="literal">null</span>||openid.equals(<span class="string">&quot;&quot;</span>))&#123;</span><br><span class="line">            <span class="keyword">return</span> ResultUtil.fail(<span class="string">&quot;00000001&quot;</span>,<span class="string">&quot;该用户不可提现&quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="comment">/** ======================================业务判断 2.openid可提现金额校验=====================================*/</span></span><br><span class="line">        <span class="comment">/** userType==1 商家身份*/</span></span><br><span class="line">        <span class="keyword">if</span>(userType == <span class="number">1</span>)&#123;</span><br><span class="line">            <span class="comment">//校验用户提现金额</span></span><br><span class="line">            <span class="comment">//1.提现金额&lt;=可提现金额 15%的抽成</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        &#125;</span><br><span class="line">        <span class="type">Float</span> <span class="variable">account</span> <span class="operator">=</span> <span class="number">0f</span>;</span><br><span class="line">        <span class="comment">/** userType==2 用户身份*/</span></span><br><span class="line">        <span class="keyword">if</span>(userType == <span class="number">2</span>)&#123;</span><br><span class="line">            <span class="comment">//校验用户提现金额</span></span><br><span class="line">            <span class="comment">//1.提现金额&lt;=可提现金额</span></span><br><span class="line">            account = appUserService.getAccount(userId);</span><br><span class="line">            <span class="keyword">if</span>(applyMoney&gt;account)&#123;</span><br><span class="line">                <span class="keyword">return</span> ResultUtil.fail(<span class="string">&quot;00000001&quot;</span>,<span class="string">&quot;非法操作：申请提现金额大于可提现金额&quot;</span>);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        <span class="comment">/** =================================业务判断 3.userId当天提现次数及当天提现金额限制==================================*/</span></span><br><span class="line">        <span class="comment">//当日提现次数 首次免手续费</span></span><br><span class="line">        List&lt;WithdrawalRecord&gt; withdrawalRecords = withdrawalRecordService.selectWithdrawalRecordOfToday(userId,openid,userType);</span><br><span class="line">        <span class="comment">//当日非初次提现</span></span><br><span class="line">        <span class="keyword">if</span>(withdrawalRecords.size()&gt;<span class="number">0</span>&amp;&amp;withdrawalRecords.size()&lt;=<span class="number">10</span>)&#123;</span><br><span class="line">            poundage = <span class="number">2f</span>;<span class="comment">//当日非初次提现，手续费为2元</span></span><br><span class="line">            desc = <span class="string">&quot;申请提现金额：&quot;</span>+applyMoney+<span class="string">&quot;元，当天已提现&quot;</span>+withdrawalRecords.size()+<span class="string">&quot;次，需扣除2元手续费&quot;</span>;</span><br><span class="line"></span><br><span class="line">            <span class="comment">//此处对用户当天累计提现金额可做限制</span></span><br><span class="line"><span class="comment">//            Float withdrawalAmountRequested = 0f;//用户今日累计已申请的提现额度</span></span><br><span class="line"><span class="comment">//            for(int i = 0;i &lt; withdrawalRecords.size();i++)&#123;</span></span><br><span class="line"><span class="comment">//                withdrawalAmountRequested = (withdrawalAmountRequested*1000+withdrawalRecords.get(i).getActualMoney()*1000)/1000;</span></span><br><span class="line"><span class="comment">//            &#125;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        &#125;<span class="keyword">else</span> <span class="keyword">if</span>(withdrawalRecords.size()&gt;<span class="number">10</span>)&#123;</span><br><span class="line">            <span class="keyword">return</span> ResultUtil.fail(<span class="string">&quot;00000001&quot;</span>,<span class="string">&quot;该用户当天提现次数上限：微信企业付款每天最多可向同一个用户付款10次&quot;</span>);</span><br><span class="line">        &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">            desc = <span class="string">&quot;申请提现金额：&quot;</span>+applyMoney+<span class="string">&quot;元，当天首次提现免手续费&quot;</span>;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="comment">/** =================================业务判断 4.一个商户同一日付款总额限额10万元==================================*/</span></span><br><span class="line">        <span class="type">Float</span> <span class="variable">amountWithdrawn</span> <span class="operator">=</span> withdrawalRecordService.selectAllWithdrawalRecordNumOfToday();<span class="comment">//商户同一日付款总额</span></span><br><span class="line">        <span class="keyword">if</span>(amountWithdrawn&gt;<span class="number">100000</span>)&#123;</span><br><span class="line">            <span class="keyword">return</span> ResultUtil.fail(<span class="string">&quot;00000001&quot;</span>,<span class="string">&quot;今日商户付款总额限额，请明天再试&quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="comment">/** ========================校验实际提现金额是否在微信企业付款实际允许的提现（0.3-5000）范围内=========================*/</span></span><br><span class="line">        <span class="type">Float</span> <span class="variable">actualMoney</span> <span class="operator">=</span> (applyMoney*<span class="number">1000</span>-poundage*<span class="number">1000</span>)/<span class="number">1000</span>;<span class="comment">//实际提现金额</span></span><br><span class="line">        <span class="keyword">if</span>(actualMoney&lt;<span class="number">0.3</span>||actualMoney&gt;<span class="number">5000</span>)&#123;</span><br><span class="line">            <span class="keyword">return</span> ResultUtil.fail(<span class="string">&quot;00000001&quot;</span>,<span class="string">&quot;扣除手续费后的实际提现金额不符:&quot;</span>+actualMoney+<span class="string">&quot;元:低于最小金额0.30元或高于5000.00元&quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        amount = Integer.parseInt((<span class="type">int</span>)((actualMoney)*<span class="number">10</span>)+<span class="string">&quot;&quot;</span>)*<span class="number">10</span>+<span class="string">&quot;&quot;</span>;<span class="comment">//微信企业付款金额 30-500000</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        <span class="comment">/** ==================================================================================================================*/</span></span><br><span class="line">        <span class="comment">/** ================================================== 封装提现所需参数 ================================================*/</span></span><br><span class="line">        <span class="comment">/** ==================================================================================================================*/</span></span><br><span class="line">        Map&lt;String, String&gt; restmap = <span class="literal">null</span>;</span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            Map&lt;String, String&gt; parm = <span class="keyword">new</span> <span class="title class_">HashMap</span>&lt;String, String&gt;();</span><br><span class="line">            parm.put(<span class="string">&quot;mch_appid&quot;</span>, APP_ID); <span class="comment">//公众账号appid</span></span><br><span class="line">            parm.put(<span class="string">&quot;mchid&quot;</span>, MCH_ID); <span class="comment">//商户号</span></span><br><span class="line">            parm.put(<span class="string">&quot;nonce_str&quot;</span>, PayUtil.getNonceStr()); <span class="comment">//随机字符串</span></span><br><span class="line">            parm.put(<span class="string">&quot;partner_trade_no&quot;</span>, PayUtil.getTransferNo()); <span class="comment">//商户订单号</span></span><br><span class="line">            parm.put(<span class="string">&quot;openid&quot;</span>, openid); <span class="comment">//用户openid oCVr20N2YLH9VQztnkZTaCj2aYYY</span></span><br><span class="line">            parm.put(<span class="string">&quot;check_name&quot;</span>, <span class="string">&quot;NO_CHECK&quot;</span>); <span class="comment">//校验用户姓名选项 OPTION_CHECK</span></span><br><span class="line">            <span class="comment">//parm.put(&quot;re_user_name&quot;, &quot;安迪&quot;); //check_name设置为FORCE_CHECK或OPTION_CHECK，则必填</span></span><br><span class="line">            parm.put(<span class="string">&quot;amount&quot;</span>,amount); <span class="comment">//转账金额</span></span><br><span class="line">            parm.put(<span class="string">&quot;desc&quot;</span>, desc); <span class="comment">//企业付款描述信息</span></span><br><span class="line">            parm.put(<span class="string">&quot;spbill_create_ip&quot;</span>, IpAddrUtil.getIpAddr(request)); <span class="comment">//Ip地址</span></span><br><span class="line">            parm.put(<span class="string">&quot;sign&quot;</span>, PayUtil.getSign(parm, API_SECRET));</span><br><span class="line"></span><br><span class="line">            <span class="type">String</span> <span class="variable">restxml</span> <span class="operator">=</span> HttpUtils.posts(TRANSFERS_PAY, XmlUtil.xmlFormat(parm, <span class="literal">false</span>));</span><br><span class="line">            restmap = XmlUtil.xmlParse(restxml);</span><br><span class="line">        &#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">            logger.error(e.getMessage(), e);</span><br><span class="line">            <span class="keyword">return</span> ResultUtil.fail(<span class="string">&quot;00000001&quot;</span>,<span class="string">&quot;转账发生异常&quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="comment">/** =================================================== 提现结果处理 ===================================================*/</span></span><br><span class="line"></span><br><span class="line">        <span class="comment">/** ============================================ 生成提现及流水记录/改变余额 ============================================*/</span></span><br><span class="line">        <span class="keyword">if</span> (CollectionUtil.isNotEmpty(restmap) &amp;&amp; <span class="string">&quot;SUCCESS&quot;</span>.equals(restmap.get(<span class="string">&quot;result_code&quot;</span>))) &#123;</span><br><span class="line">            logger.info(<span class="string">&quot;转账成功&quot;</span>);</span><br><span class="line">            Map&lt;String, String&gt; transferMap = <span class="keyword">new</span> <span class="title class_">HashMap</span>&lt;&gt;();</span><br><span class="line">            transferMap.put(<span class="string">&quot;partnerTradeNo&quot;</span>, restmap.get(<span class="string">&quot;partner_trade_no&quot;</span>));<span class="comment">//商户转账订单号</span></span><br><span class="line">            transferMap.put(<span class="string">&quot;paymentNo&quot;</span>, restmap.get(<span class="string">&quot;payment_no&quot;</span>)); <span class="comment">//微信订单号</span></span><br><span class="line">            transferMap.put(<span class="string">&quot;paymentTime&quot;</span>, restmap.get(<span class="string">&quot;payment_time&quot;</span>)); <span class="comment">//微信支付成功时间</span></span><br><span class="line"></span><br><span class="line">            <span class="comment">//生成提现记录</span></span><br><span class="line">            withdrawalRecordService.insert(<span class="keyword">new</span> <span class="title class_">WithdrawalRecord</span>(id,userType,userId,applyMoney,poundage,actualMoney,<span class="number">1</span>,restmap.get(<span class="string">&quot;partner_trade_no&quot;</span>),restmap.get(<span class="string">&quot;payment_no&quot;</span>),</span><br><span class="line">                    restmap.get(<span class="string">&quot;payment_time&quot;</span>)==<span class="literal">null</span>?<span class="literal">null</span>:DateUtil.strToDate(restmap.get(<span class="string">&quot;payment_time&quot;</span>),<span class="string">&quot;yyyy-MM-dd HH:mm:ss&quot;</span>),openid,desc,restmap.get(<span class="string">&quot;spbill_create_ip&quot;</span>),<span class="string">&quot;0&quot;</span>));</span><br><span class="line">            <span class="comment">//生成流水表</span></span><br><span class="line">            <span class="type">String</span> <span class="variable">waterId</span> <span class="operator">=</span> UUID.randomUUID().toString().replaceAll(<span class="string">&quot;-&quot;</span>, <span class="string">&quot;&quot;</span>);</span><br><span class="line">            Map&lt;String,Object&gt; map = <span class="keyword">new</span> <span class="title class_">HashMap</span>&lt;&gt;();</span><br><span class="line">            map.put(<span class="string">&quot;id&quot;</span>,waterId);<span class="comment">//编号</span></span><br><span class="line">            map.put(<span class="string">&quot;userId&quot;</span>,userId);<span class="comment">//用户id</span></span><br><span class="line">            map.put(<span class="string">&quot;title&quot;</span>,<span class="string">&quot;提现&quot;</span>);<span class="comment">//该流水的标题</span></span><br><span class="line">            map.put(<span class="string">&quot;waterType&quot;</span>,<span class="number">2</span>);<span class="comment">//商家流水类型1.场地收入 2.提现    用户流水类型1.分销收入 2.提现 3.预订场地</span></span><br><span class="line">            map.put(<span class="string">&quot;incomeExpense&quot;</span>,<span class="number">1</span>);<span class="comment">//收入还是支出 0.收入 1.支出</span></span><br><span class="line">            map.put(<span class="string">&quot;applyMoney&quot;</span>,applyMoney);<span class="comment">//申请提现金额</span></span><br><span class="line">            map.put(<span class="string">&quot;poundage&quot;</span>,poundage);<span class="comment">//手续费</span></span><br><span class="line">            map.put(<span class="string">&quot;actualMoney&quot;</span>,actualMoney);<span class="comment">//实际金额</span></span><br><span class="line">            map.put(<span class="string">&quot;whetherToAccount&quot;</span>,<span class="number">1</span>);<span class="comment">//是否到账0.未到账1.已到账</span></span><br><span class="line">            <span class="keyword">if</span>(userType==<span class="number">1</span>)&#123;</span><br><span class="line">                sysUserService.insertUserWater(map);</span><br><span class="line">                <span class="comment">//改变用户可提现余额</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span>(userType==<span class="number">2</span>)&#123;</span><br><span class="line">                appUserService.insertUserWater1(map);</span><br><span class="line">                <span class="comment">//改变用户可提现余额</span></span><br><span class="line">                appUserService.updateUserAccount(userId,(account*<span class="number">1000</span>-applyMoney*<span class="number">1000</span>)/<span class="number">1000</span>);<span class="comment">//float精度问题</span></span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">return</span> ResultUtil.success(transferMap);</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="comment">/** =================================================3.转账失败========================================================*/</span></span><br><span class="line">        <span class="keyword">else</span> &#123;</span><br><span class="line">            <span class="keyword">if</span> (CollectionUtil.isNotEmpty(restmap)) &#123;</span><br><span class="line">                logger.info(<span class="string">&quot;转账失败：&quot;</span> + restmap.get(<span class="string">&quot;err_code&quot;</span>) + <span class="string">&quot;:&quot;</span> + restmap.get(<span class="string">&quot;err_code_des&quot;</span>));</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">return</span> ResultUtil.fail(<span class="string">&quot;00000001&quot;</span>,<span class="string">&quot;转账失败&quot;</span>+restmap.get(<span class="string">&quot;err_code_des&quot;</span>));</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 企业向个人转账查询</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> request</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> response</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> tradeno 商户转账订单号</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> callback</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="meta">@PostMapping(value = &quot;/pay/query&quot;)</span></span><br><span class="line">    <span class="keyword">public</span> Result <span class="title function_">orderPayQuery</span><span class="params">(HttpServletRequest request, HttpServletResponse response, String tradeno,</span></span><br><span class="line"><span class="params">                              String callback)</span> &#123;</span><br><span class="line">        <span class="keyword">if</span> (StringUtil.isEmpty(tradeno)) &#123;</span><br><span class="line">            <span class="keyword">return</span> ResultUtil.fail(<span class="string">&quot;00000001&quot;</span>,<span class="string">&quot;转账订单号不能为空&quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        Map&lt;String, String&gt; restmap = <span class="literal">null</span>;</span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            Map&lt;String, String&gt; parm = <span class="keyword">new</span> <span class="title class_">HashMap</span>&lt;String, String&gt;();</span><br><span class="line">            parm.put(<span class="string">&quot;appid&quot;</span>, APP_ID);</span><br><span class="line">            parm.put(<span class="string">&quot;mch_id&quot;</span>, MCH_ID);</span><br><span class="line">            parm.put(<span class="string">&quot;partner_trade_no&quot;</span>, tradeno);</span><br><span class="line">            parm.put(<span class="string">&quot;nonce_str&quot;</span>, PayUtil.getNonceStr());</span><br><span class="line">            parm.put(<span class="string">&quot;sign&quot;</span>, PayUtil.getSign(parm, API_SECRET));</span><br><span class="line"></span><br><span class="line">            <span class="type">String</span> <span class="variable">restxml</span> <span class="operator">=</span> HttpUtils.posts(TRANSFERS_PAY_QUERY, XmlUtil.xmlFormat(parm, <span class="literal">true</span>));</span><br><span class="line">            restmap = XmlUtil.xmlParse(restxml);</span><br><span class="line">        &#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">            logger.error(e.getMessage(), e);</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="keyword">if</span> (CollectionUtil.isNotEmpty(restmap) &amp;&amp; <span class="string">&quot;SUCCESS&quot;</span>.equals(restmap.get(<span class="string">&quot;result_code&quot;</span>))) &#123;</span><br><span class="line">            <span class="comment">// 订单查询成功 处理业务逻辑</span></span><br><span class="line">            logger.info(<span class="string">&quot;订单查询：订单&quot;</span> + restmap.get(<span class="string">&quot;partner_trade_no&quot;</span>) + <span class="string">&quot;支付成功&quot;</span>);</span><br><span class="line">            Map&lt;String, String&gt; transferMap = <span class="keyword">new</span> <span class="title class_">HashMap</span>&lt;&gt;();</span><br><span class="line">            transferMap.put(<span class="string">&quot;partnerTradeNo&quot;</span>, restmap.get(<span class="string">&quot;partner_trade_no&quot;</span>));<span class="comment">//商户转账订单号</span></span><br><span class="line">            transferMap.put(<span class="string">&quot;openid&quot;</span>, restmap.get(<span class="string">&quot;openid&quot;</span>)); <span class="comment">//收款微信号</span></span><br><span class="line">            transferMap.put(<span class="string">&quot;paymentAmount&quot;</span>, restmap.get(<span class="string">&quot;payment_amount&quot;</span>)); <span class="comment">//转账金额</span></span><br><span class="line">            transferMap.put(<span class="string">&quot;transferTime&quot;</span>, restmap.get(<span class="string">&quot;transfer_time&quot;</span>)); <span class="comment">//转账时间</span></span><br><span class="line">            transferMap.put(<span class="string">&quot;desc&quot;</span>, restmap.get(<span class="string">&quot;desc&quot;</span>)); <span class="comment">//转账描述</span></span><br><span class="line">            <span class="keyword">return</span> ResultUtil.success(transferMap);</span><br><span class="line">        &#125;<span class="keyword">else</span> &#123;</span><br><span class="line">            <span class="keyword">if</span> (CollectionUtil.isNotEmpty(restmap)) &#123;</span><br><span class="line">                logger.info(<span class="string">&quot;订单转账失败：&quot;</span> + restmap.get(<span class="string">&quot;err_code&quot;</span>) + <span class="string">&quot;:&quot;</span> + restmap.get(<span class="string">&quot;err_code_des&quot;</span>));</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">return</span> ResultUtil.fail(<span class="string">&quot;00000001&quot;</span>,<span class="string">&quot;订单转账失败&quot;</span>);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

    </div>

    
    
    

    <footer class="post-footer">
          <div class="reward-container">
  <div>请我一杯咖啡吧！</div>
  <button>
    赞赏
  </button>
  <div class="post-reward">
      <div>
        <img src="/images/wechatpay.jpg" alt="Jaron Chim 微信">
        <span>微信</span>
      </div>
      <div>
        <img src="/images/alipay.jpg" alt="Jaron Chim 支付宝">
        <span>支付宝</span>
      </div>

  </div>
</div>

          <div class="post-tags">
              <a href="/tags/WeChat/" rel="tag"># WeChat</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/2019/05/13/%E9%9B%B6%E5%9F%BA%E7%A1%80%E5%AD%A6%E4%B9%A0Mahout/" rel="prev" title="零基础学习Mahout">
                  <i class="fa fa-angle-left"></i> 零基础学习Mahout
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/2019/05/20/Java%E7%9A%84Excel%E8%AF%BB%E5%86%99-easyExcel%E6%96%B9%E6%B3%95%E5%B0%81%E8%A3%85/" rel="next" title="Java的Excel读写-easyExcel方法封装">
                  Java的Excel读写-easyExcel方法封装 <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="beian"><a href="https://beian.miit.gov.cn/" rel="noopener" target="_blank">粤ICP备2025405034号-1 </a>
  </div>
  <div class="copyright">
    &copy; 2016 – 
    <span itemprop="copyrightYear">2025</span>
    <span class="with-love">
      <i class="fa fa-user"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">Jaron Chim</span>
  </div>
<div class="busuanzi-count">
    <span class="post-meta-item" id="busuanzi_container_site_uv">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-item" id="busuanzi_container_site_pv">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>

    </div>
  </footer>

  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>
  <div class="sidebar-dimmer"></div>
  <a role="button" class="book-mark-link book-mark-link-fixed"></a>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>

</body>
</html>
